<script setup lang="ts">
import {taskStore} from "@/store/task.ts";
import {bannerList} from "@/api/task.ts";
import {showToast} from "vant";

const store = taskStore()
const getBannerList = async () => {
  const res = await bannerList({
    type: 2
  })
  if (res) {
    store.setBannerList(res.list)
  } else {
    showToast(res.msg)
  }
}
if (store.bannerList.length === 0) getBannerList()
</script>
<template>
  <van-swipe :autoplay="3000" lazy-render>
    <van-swipe-item v-for="(item, index) in store.bannerList" :key="index">
      <a :href="item.url" target="_blank" v-if="item.url">
        <img alt="轮播图片" :src="item.picture"/>
      </a>
      <img v-else alt="轮播图片" :src="item.picture"/>
    </van-swipe-item>
  </van-swipe>
</template>

<style scoped>
img {
  width: 100%;
  height: 7.47rem;
  border-radius: 0.5rem;
}

:deep(.van-swipe__indicators) {
  display: none;
}
:deep(.van-swipe__track) {
  height: 7.47rem;
}
</style>